<?php

namespace app\api\controller;

use app\common\exception\BusinessException;

class FileManage extends Base
{
    public function upload()
    {
        // 请求参数
        $app = $this->request->param('app');
        $file = $this->request->file('file');

        // 检查参数
        if (empty($app)) {
            throw new BusinessException("请选择app");
        }
        if (empty($file)) {
            throw new BusinessException("请选择文件");
        }

        // 上传文件
        $res = app(\app\api\logic\FileManage::class)->upload($app, $file);
        return $this->response([$res]);
    }
}